#include "AnaDef.h"

void print(const TString tag)
{
  TObjArray *obj = 0x0;
  const TString nn(Form("TRDCalibObj%s", tag.Data()));
  //old const TString nn(Form("TRD%sCalibObj", tag.Data()));
  gDirectory->GetObject(nn, obj);
  if(!obj){
    printf("no obj!! %s\n", tag.Data());
    gDirectory->ls();
    exit(1);
  }

  TVectorD *aa=0x0;
  aa=(TVectorD*) obj->At(0);

  for(Int_t ibin=0; ibin<aa->GetNrows(); ibin++){
    const Double_t cont = (*aa)[ibin];
    if(fabs(cont)>1e-12){
      printf("outcalibobj%s %d %15.6e\n", tag.Data(), ibin, cont);
    }
  }
}

int main(int argc, char *argv[])
{
  for(int ii=0; ii<argc; ii++)
    printf("%d %s\n", ii, argv[ii]);

  TFile::Open(argv[1]);

  print("PHQ0");
  print("PHQ1");
  print("PHQ2");
  print("PHQ3");
  print("PHQ4");
  print("PHQ5");
  print("PHQ6");
  print("PHQ7");

  print("Gain");
  print("T0");
  print("Vd");
}
